{
 "cells": [
  {
   "cell_type": "markdown",
   "metadata": {},
   "source": [
    "@Testのアノテーションが無いとエラーになる"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 24,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "import static org.junit.Assert.*;\n",
      "import org.junit.Test;\n",
      "\n",
      "public class JUnitTest {\n",
      "        public static int num(){\n",
      "                return 10;\n",
      "        }\n",
      "\n",
      "        @Test\n",
      "        public void test(){\n",
      "                assertEquals(10, num());\n",
      "        }\n",
      "}\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "name=JUnitTest\n",
    "\n",
    "### ソースの編集\n",
    "cat <<- EOS > ${name}.java\n",
    "import static org.junit.Assert.*;\n",
    "import org.junit.Test;\n",
    "\n",
    "public class ${name} {\n",
    "        public static int num(){\n",
    "                return 10;\n",
    "        }\n",
    "\n",
    "        @Test\n",
    "        public void test(){\n",
    "                assertEquals(10, num());\n",
    "        }\n",
    "}\n",
    "EOS\n",
    "\n",
    "### ソースの確認\n",
    "cat ${name}.java"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 25,
   "metadata": {
    "collapsed": false,
    "deletable": true,
    "editable": true
   },
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "JUnit version 4.11\n",
      ".\n",
      "Time: 0.003\n",
      "\n",
      "OK (1 test)\n",
      "\n"
     ]
    }
   ],
   "source": [
    "%%bash\n",
    "name=JUnitTest\n",
    "\n",
    "### コンパイル\n",
    "javac -cp .:junit-4.11.jar ${name}.java\n",
    "\n",
    "### 実行\n",
    "java -cp .:junit-4.11.jar org.junit.runner.JUnitCore ${name}"
   ]
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.6.1"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
